package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.EmployeeDTO;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * @description: 新增员工
     * @param: [employee]
     * @return: void
     * @author Wait葡萄成熟时
     * @date: 上午11:22 2024/11/3
     */
    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into employee(id,username,name,phone,sex,id_number,password,status,create_time,update_time,create_user,update_user) " +
            "values(#{id},#{username},#{name},#{phone},#{sex},#{idNumber},#{password},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add( Employee employee);


    /** 
     * @description:  分页查询
     * @param: employeePageQueryDTO
     * @return: Page<Employee>
     * @author Wait葡萄成熟时
     * @date: 上午11:26 2024/11/3
     */
    Page<Employee> selectEmpPage(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * @description: 状态开关
     * @param: [build]
     * @return: void
     * @author Wait葡萄成熟时
     * @date: 下午8:53 2024/11/3
     */
    @AutoFill(value = OperationType.UPDATE)
    @Update("update employee set status=#{status},update_time=#{updateTime} where id=#{id}")
    void startOrStop(Employee build);


    /**
     * @description: 查询
     * @param: [id]
     * @return: com.sky.entity.Employee
     * @author Wait葡萄成熟时
     * @date: 下午9:49 2024/11/3
     */
    @Select("select * from employee where id=#{id}")
    Employee selectEmpById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void updateEmp(Employee employee);

}
